package model

import (
	__ "user-srv/basic/proto"

	"gorm.io/gorm"
)

type Shop struct {
	gorm.Model
	Name        string `gorm:"type:varchar(20);not null;unique;index" json:"name"`
	Description string `gorm:"type:varchar(30)" json:"description"`
	Sort        int64  `gorm:"type:int(11)" json:"sort"`
}

func (s *Shop) GetOneFile(db *gorm.DB) error {
	return db.Model(s).Where("name = ?", s.Name).Limit(1).Find(&s).Error
}
func (s *Shop) Create(db *gorm.DB) error {
	return db.Model(s).Create(&s).Error
}
func (s *Shop) Del(db *gorm.DB) error {
	return db.Model(s).Delete(&s).Error
}
func (s *Shop) GetCover(db *gorm.DB) (list []*__.ShopList, err error) {
	err = db.Model(s).Order("create_time desc").Find(&list).Error
	return list, err
}
